// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    swiperList:[],
    msg:{},
    recommendList:[]
  },
 onLoad(){
   this.getSwiperList()
   this.getMsg()
   this.getRecommendList()
 },
//  获取轮播图数据
 getSwiperList(){
   wx.request({
     url: 'https://api.it120.cc/noodles/banner/list',
     method:'GET',
     data:{},
     success:(res)=>{
      //  console.log(res.data.data);
       this.setData({
         swiperList:res.data.data
       })
     }
   })
 },
//  获取店铺信息
getMsg(){
  wx.request({
    url: 'https://api.it120.cc/noodles/shop/subshop/list',
    method:'POST',
    data:{},
    success:(res)=>{
      // console.log(res.data.data);
      this.setData({
        msg:res.data.data[0]
      })
    }
  })
},
// 获取店家推荐
getRecommendList(){
  wx.request({
    url: 'https://api.it120.cc/noodles/shop/goods/list',
    method:'POST',
    data:{},
    success:(res)=>{
      // console.log(res.data.data);
      this.setData({
        recommendList:res.data.data
      })
    }
  })
},
// 点击跳转到商品详情
onDetails(e){
  // console.log(e.currentTarget.dataset.id);
  let _id=e.currentTarget.dataset.id
  wx.navigateTo({
    url: "/pages/details/details?id="+_id,
    success: (result) => {
      // console.log(1);
    },
    fail: (res) => {
      console.log(res);
      // console.log(2);
    },
    complete: (res) => {},
  })
}
})
